# coding=utf-8
import maya.cmds as cmds
import os
import pipeline
import core.conf as FileNameSplit
import re
#import core as timelimit
def Sound():
	#if timelimit.ProductActivation().Win() == 0:
	#	return

	Project_Sound = pipeline.LocalPath_ProjectSettingRead("Project_ServerX_Path")
	#print Project_Sound
	#try:
	File_sceneName = cmds.file(q=1, sceneName=1, shortName=1)
	#Sound_Wav = Project_Sound + '/' + basenameEx[0] + '/' + basenameEx[2] + '.wav'
	Sound_path = Project_Sound + '/Sound/' + re.search(FileNameSplit.Set(),File_sceneName).group() + '/'
	#print Sound_path
	old_sound = cmds.ls(type='audio')
	if old_sound:
		cmds.delete(old_sound)
	File_sound = FileNameSplit.Set() + FileNameSplit.Set_Split() + FileNameSplit.Events() + FileNameSplit.Events_Split() + FileNameSplit.Lens()
	#print  re.search(File_sound, File_sceneName).group(),
	if re.search(File_sound,File_sceneName).group() + '-sou.wav' in os.listdir(Sound_path):
		cmds.file(Sound_path + re.search(File_sound,File_sceneName).group() + '-sou.wav', i=1, type="audio", ignoreVersion=1, ra=1, mergeNamespacesOnClash=1, namespace=':',options="o=101", pr=1, importTimeRange="combine")
	else:
		cmds.inViewMessage(amg=u" <hl>没有音频文件！</hl>", pos='midCenter', fade=True)
#Sound()
